package com.longcai.piaojia.dialog;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.longcai.piaojia.R;

/**
 * Created by Administrator on 2016/8/31.
 */
public abstract class WarnningDialog extends BaseDialog {

    public WarnningDialog (Context context, String message, String leftText, String rightText){
        super(context);

        setContentView(R.layout.dialog_warnning);

        ((TextView) findViewById(R.id.alert_message)).setText(message);
        ((TextView) findViewById(R.id.alert_cancel)).setText(leftText);
        ((TextView) findViewById(R.id.alert_confirm)).setText(rightText);

        View.OnClickListener listener = new View.OnClickListener() {

            @Override
            public void onClick(View v) {

                switch (v.getId()){

                    case R.id.alert_confirm:

                        onConfirm();

                        break;

                }

                dismiss();

            }

        };

        findViewById(R.id.alert_cancel).setOnClickListener(listener);
        findViewById(R.id.alert_confirm).setOnClickListener(listener);
    }



    public WarnningDialog(Context context, String message) {

        super(context);

        setContentView(R.layout.dialog_warnning);

        ((TextView) findViewById(R.id.alert_message)).setText(message);


        View.OnClickListener listener = new View.OnClickListener() {

            @Override
            public void onClick(View v) {

                switch (v.getId()){

                    case R.id.alert_confirm:

                        onConfirm();

                        break;

                }

                dismiss();

            }

        };

        findViewById(R.id.alert_cancel).setOnClickListener(listener);
        findViewById(R.id.alert_confirm).setOnClickListener(listener);

    }

    protected abstract void onConfirm();


}
